<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                template="./../../template/templateSGPF.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="corpo da página">
        <script>
            function decideMessage(value) {
                if (value) {
                    if (value.dialogConfimation === 'salvar') {
                        PF('save').show();
                    }
                    if (value.dialogConfimation === 'update') {
                        update.show();
                    }
                    if (value.dialogConfimation === 'error') {
                        error.show();
                    }
                }
            }
            function verify(value) {
                if (value.flag === "salvar") {
                    PF('confirmacao').show();
                }
                if (value.flag === "ok") {
                    PF('save').show();
                }
            }
            function removerEspacos(inputtext) {
                inputtext.value = inputtext.value.replace(/^\s+|\s+$/g, "");
            }

            function alteraMaiusculo(inputtext) {
                inputtext.value = inputtext.value.toUpperCase();
            }

        </script>

        <center><h1>#{contratoServidorBean.titulo} </h1></center>        
        <h:form id="frmCadContrato" prependId="false">
            <div class="row-fluid">
                <div class="pull-right">                        
                    <p:commandButton style="width: 100px;"
                                     value="Salvar"                                    
                                     icon="ui-icon-disk"
                                     oncomplete="verify(args);"
                                     action="#{contratoServidorBean.verificaCamposDialog()}"                                     
                                     update=":formConfirm"
                                     />
                    <p:commandButton style="width: 100px;" 
                                     icon="ui-icon-circle-close"
                                     value="Cancelar" 
                                     action="#{contratoServidorBean.cancelar()}"
                                     ajax="false"
                                     update=":frmCadContrato"/>
                </div>
            </div>

            <div class="row-fluid">
                <div class="span6">
                    <div class="well-custom3">

                        <div class="row-fluid" >
                            <strong for="Servidor" class="font-color-green">
                                Servidor <strong style="color:red">*</strong>:</strong>                             
                        </div>
                        <div class="row-fluid">
                            <div class="span6">
                                <p:selectOneMenu id="sloServidor" 
                                                 style="width: 97%; color: black"
                                                 value="#{contratoServidorBean.servidor}"
                                                 filter="true"
                                                 filterMatchMode="startsWith"
                                                 converter="servidorConverter"
                                                 disabled="#{contratoServidorBean.habilitaCampo}"
                                                 >
                                    <f:selectItem itemLabel="Selecione o Servidor" itemValue="" />
                                    <f:selectItems value="#{contratoServidorBean.servidores}"
                                                   var="servidor"
                                                   itemValue="#{servidor}"
                                                   itemLabel="#{servidor.nome}"
                                                   class="font-color-black"
                                                   />
                                    <p:ajax update="dataIni txt_matricula txt_vinculo"/>
                                </p:selectOneMenu>
                            </div>
                            <div class="span6">
                                <p:messages for="msgServidor" showDetail="true" autoUpdate="true" closable="true"/>                                           
                            </div>
                        </div>

                        <div class="row-fluid" style="margin-top: 2%">
                            <strong for="Data inicial" class="font-color-green">
                                Data inicial<strong style="color:red">*</strong>:</strong> 
                        </div>
                        <div class="row-fluid">
                            <div class="span6">
                                <p:calendar id="dataIni"  
                                            value="#{contratoServidorBean.dataInicial}" 
                                            locale="pt" 
                                            showButtonPanel="true" 
                                            navigator="true" 
                                            yearRange="c-64:c+36"
                                            /> 
                            </div>
                            <div class="span6">
                                <p:messages for="msgData" showDetail="true" autoUpdate="true" closable="true"/>                                           
                            </div>
                        </div>

                        <div class="row-fluid" >
                            <strong for="Data inicial" class="font-color-green">
                                Data final<strong style="color:red">*</strong>:</strong> 
                        </div>
                        <div class="row-fluid">
                            <div class="span6">
                                <p:calendar id="dataFim"  
                                            value="#{contratoServidorBean.cs.dataFim}" 
                                            locale="pt" 
                                            showButtonPanel="true" 
                                            navigator="true" 
                                            yearRange="c-64:c+36"
                                            /> 
                            </div>
                            <div class="span6">
                                <p:messages for="msgDataFim" showDetail="true" autoUpdate="true" closable="true"/>                                           
                            </div>
                        </div>

                        <div class="row-fluid" >
                            <strong for="Sigla" class="font-color-green">
                                Matrícula/Vínculo <strong style="color:red">*</strong>:</strong> 
                        </div>
                        <div class="row-fluid">
                            <div class="span6">
                                <p:inputText id="txt_matricula" style="width: 74%; height: 30px;"
                                             value="#{contratoServidorBean.mat}" 
                                             class="form-control"
                                             disabled="#{contratoServidorBean.habilitaImputText}"
                                             maxlength="20"/>                                
                                <p:inputText id="txt_vinculo" style="width: 20%; height: 30px; margin-left: 3%"
                                             value="#{contratoServidorBean.vinc}" 
                                             class="form-control"
                                             disabled="#{contratoServidorBean.habilitaImputText}"
                                             maxlength="2"/> 
                                <pe:keyFilter for="txt_matricula" mask="num"/>
                                <pe:keyFilter for="txt_vinculo" mask="num"/>
                            </div>
                            <div class="span6">
                                <p:messages for="msgMatricula" showDetail="true" autoUpdate="true" closable="true"/>                                           
                            </div>
                        </div>


                    </div>
                </div>
                <div class="span6">
                    <div class="well-custom3">
                        <div class="row-fluid">
                            <strong for="sloStatus" class="font-color-green">
                                Status: </strong> 
                        </div>
                        <div class="row-fluid">
                            <div class="span6">
                                <p:selectOneMenu id="sloStatus"  
                                                 style="width: 97%; color: black;"
                                                 value="#{contratoServidorBean.cs.status}">
                                    <f:selectItem itemLabel="Ativo" itemValue="ativo"
                                                  class="font-color-black"/>
                                    <f:selectItem itemLabel="Inativo" itemValue="inativo" 
                                                  class="font-color-black"/>
                                    <f:selectItem itemLabel="Prorrogado" itemValue="prorrogado" 
                                                  class="font-color-black"/>
                                </p:selectOneMenu>
                            </div>
                            <div class="span6">
                                <p:messages for="msgStatus" showDetail="true" autoUpdate="true" closable="true"/>                                           
                            </div>
                        </div>
                        <div class="row-fluid" style="margin-top: 2%">
                            <strong for="slodoe" 
                                    class="font-color-green" 
                                    title="Número da publicação no diário oficial contendo informaçoes sobre a contrataçao do servidor ">
                                Número do DOE: </strong> 
                        </div>
                        <div class="row-fluid">
                            <div class="span6">
                                <p:inputText id="txt_doe" style="width: 97%; height: 30px;  "                                                     
                                             value="#{contratoServidorBean.cs.numeroDoe}"
                                             maxlength="7"/>
                                <pe:keyFilter for="txt_doe" mask="num"/>
                            </div>
                            <div class="span6">
                                <p:messages for="msgDoe" showDetail="true" autoUpdate="true" closable="true"/>
                            </div>
                        </div>

                        <div class="row-fluid">
                            <strong for="Data publicacao" class="font-color-green">
                                Data de publicação<strong style="color:red">*</strong>:</strong> 
                        </div>
                        <div class="row-fluid">
                            <div class="span6">
                                <p:calendar id="dataPbl"  
                                            value="#{contratoServidorBean.cs.dataPublicacao}" 
                                            locale="pt" 
                                            showButtonPanel="true" 
                                            navigator="true" 
                                            yearRange="c-64:c+36"
                                            /> 
                            </div>
                            <div class="span6">
                                <p:messages for="msgDataPublicacao" showDetail="true" autoUpdate="true" closable="true"/>                                           
                            </div>
                        </div>

                        <div class="row-fluid">                                    
                            <strong for="Observacao" class="font-color-green">
                                Observação:</strong> 
                        </div>
                        <div class="row-fluid">
                            <div class="span6">
                                <p:inputTextarea rows="2" 
                                                 cols="30" 
                                                 counterTemplate="{0} caractere(s)."  
                                                 counter="counter"  
                                                 required="false" 
                                                 id="txaObservacao" 
                                                 value="#{contratoServidorBean.cs.observacao}" 
                                                 autoResize="false"  
                                                 maxlength="500"
                                                 style="width: 97%"
                                                 styleClass="no-resize"
                                                 onblur="removerEspacos(this)"
                                                 onkeyup="alteraMaiusculo(this)"/>
                                <h:outputText id="counter" class="font-color-green"/>                                            
                            </div>
                        </div>

                    </div>
                </div>
            </div>


        </h:form>
        
        <p:confirmDialog global="true"
                         closable="false" 
                         message="O Cadastro foi salvo com sucesso!"  
                         header="Alerta" severity="alert" 
                         widgetVar="save"> 
            <h:form>
                <p:commandButton  id="buttonOK" 
                                  onclick="save.hide();" 
                                  value="OK" 
                                  ajax="false"
                                  action="#{contratoServidorBean.irLista()}"
                                  >
                </p:commandButton> 
            </h:form>
        </p:confirmDialog>
        <p:confirmDialog 
            global="true"
            header="Confirmação"
            message="Você confirma o envio destas informações?" 
            id="confirmDialog"                               
            severity="alert" 
            widgetVar="confirmacao" 
            closable="false" 
            width="700"
            >
            <h:form id="formConfirm">
                <div class="row-fluid">                        
                    <div class="well-custom2">   
                        <div class="pull-left">
                            <div class="row-fluid">
                                <strong for="Nome" class="font-color-green">
                                    Servidor<strong style="color:red">*</strong>: </strong> 
                                <h:outputText value="#{contratoServidorBean.cs.servidor.nome} "/>
                            </div>
                            <div class="row-fluid"> 
                                <strong for="Sigla" class="font-color-green">
                                    Data inicial:</strong> 
                                <h:outputText value="#{contratoServidorBean.cs.formataDataInicio} "/>                                
                            </div>
                            <div class="row-fluid"> 
                                <strong for="CEP" class="font-color-green">
                                    Data final: </strong> 
                                <h:outputText value="#{contratoServidorBean.cs.formataDataFim} "/> 
                            </div>
                            <div class="row-fluid"> 
                                <strong for="Endereco" class="font-color-green">
                                    Matrícula/vínculo: </strong> 
                                <h:outputText value="#{contratoServidorBean.cs.matricula} "/> /
                                <h:outputText value="#{contratoServidorBean.cs.vinculo} "/> 
                            </div>
                        </div>                                                                                

                        <div class="pull-right">
                            <div class="row-fluid">                                    
                                <strong for="Estado" class="font-color-green">
                                    Status: <strong style="color:red">*</strong>: </strong> 
                                <h:outputText value="#{contratoServidorBean.cs.status} " />                                
                            </div>
                            <div class="row-fluid">                                    
                                <strong for="Estado" class="font-color-green">
                                    Nº DOE: <strong style="color:red">*</strong>: </strong> 
                                <h:outputText value="#{contratoServidorBean.cs.numeroDoe} " />                                
                            </div>
                            <div class="row-fluid">                                    
                                <strong for="Estado" class="font-color-green">
                                    Data de publicação: <strong style="color:red">*</strong>: </strong> 
                                <h:outputText value="#{contratoServidorBean.cs.formataPublicacao} " />                                
                            </div>
                            <div class="row-fluid">                                    
                                <strong for="Municipio" class="font-color-green">
                                    Observação: <strong style="color:red">*</strong>: </strong> 
                                <div class="row-fluid"> 
                                    <div class="span6">
                                        <p:inputTextarea value="#{contratoServidorBean.cs.observacao}" 
                                                         readonly="true"
                                                         rows="2"
                                                         cols="30"
                                                         autoResize="false" 
                                                         styleClass="no-resize input"
                                                         style="width: 208px; color: blue;"
                                                         />                            
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>                        
                    <div class="pull-left">   
                        <p:commandButton id="confirm" 
                                         onclick="PF('confirmacao').hide();"  
                                         value="Sim" 
                                         oncomplete="verify(args);"
                                         actionListener="#{contratoServidorBean.salvar()}"
                                         update=":frmCadContrato"
                                         />                          
                        <p:commandButton id="decline" value="Não" 
                                         onclick="PF('confirmacao').hide();" 
                                         >                                         
                        </p:commandButton>
                    </div>
                </div>
            </h:form>
        </p:confirmDialog>

    </ui:define>

</ui:composition>
